package com.arron.algorithm.huawei.简单;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class 合并表记录 {
    public static void main(String[] args) {
        Map<Integer,Integer> map = new TreeMap<>();
        Scanner in = new Scanner(System.in);


        // 注意 hasNext 和 hasNextLine 的区别
        int t = in.nextInt();
        for(int i =0;i<t;i++){
            int k = in.nextInt();
            int v = in.nextInt();
            map.put(k,map.getOrDefault(k,0)+v);

        }
        for(Map.Entry<Integer,Integer> e : map.entrySet()){
            System.out.print(e.getKey()+" "+e.getValue());
        }


    }
}
